<?php

use think\facade\Route;

/**
 * 管理端
 */
Route::group('manage', function () {
    /**
     * 不需要登录的模块
     */
    Route::group('login', function () {
        Route::get('/', 'AuthController@login'); //登录页面
        Route::post('/', 'AuthController@loginIn'); //登录
        Route::delete('/', 'AuthController@loginOut'); //退出
    });
    Route::get('/captcha', 'AuthController@getCaptcha');

    /**
     * 需要登录的模块
     */
    Route::group('', function () {
        Route::get("/", 'IndexController@index');
        Route::get("/main", 'IndexController@main');

        /**
         * 修改密码模块
         */
        Route::group('password', function () {
            Route::get('/', 'AuthController@editPasswordPage'); //修改密码页面
            Route::put('/', 'AuthController@updatePassword'); //修改密码页面
        });


        /**
         * 客户端配置
         */
        Route::group('clients', function () {
            Route::group('pages', function () {
                Route::get('/', 'ClientsController@index');//列表界面
                Route::get('/<id>', 'ClientsController@edit')->pattern(['id' => '\d+']);//详细界面
            });
            Route::get('/', 'ClientsController@getRecordList'); //获取列表数据
            Route::post('/', 'ClientsController@createRecord'); //新增数据
            Route::put('/<id>', 'ClientsController@updateRecord')->pattern(['id' => '\d+']); //修改数据
            Route::delete('/<id>', 'ClientsController@deleteRecord')->pattern(['id' => '\d+']); //删除数据
        });

        /**
         * 功能模块
         */
        Route::group('modules', function () {
            Route::group('pages', function () {
                Route::get('/', 'ModuleController@index');//列表页面
                Route::get('/<id>', 'ModuleController@moduleInfoPage')->pattern(['id' => '\d+']);//详细界面
            });

            Route::get('/', 'ModuleController@getRecordList'); //获取列表数据
            Route::post('/', 'ModuleController@createModule'); //新增数据
            Route::put('/<id>', 'ModuleController@updateModule')->pattern(['id' => '\d+']); //修改数据
            Route::delete('/<id>', 'ModuleController@deleteModule')->pattern(['id' => '\d+']); //删除数据


            /**
             * 权限资源
             */
            Route::group('rights', function () {
                Route::group('pages', function () {
                    Route::get('/', 'ModuleController@rightListPage');//列表页面
                    Route::get('/<id>', 'ModuleController@rightEditPage')->pattern(['id' => '\d+']);//权限详细界面
                });
                Route::get('/', 'ModuleController@getRightsList'); //获取列表数据
                Route::post('/', 'ModuleController@createRights'); //新增权限
                Route::put('/<id>', 'ModuleController@updateRights')->pattern(['id' => '\d+']); //修改权限
                Route::delete('/<id>', 'ModuleController@deleteRights')->pattern(['id' => '\d+']);//删除权限
                Route::put('/ismenu', 'ModuleController@switchRightsIsMenu');//切换权限是否菜单
                Route::put('/isshow', 'ModuleController@switchRightsIsShow');//切换权限是否显示
                Route::post('/icon', 'ModuleController@uploadMenuIcon'); //上传图标
            });
        });

        /**
         * 外部接口
         */
        Route::group('outapi', function () {

            /**
             * 接口资源
             */
            Route::group('resources', function () {
                Route::group('pages', function () {
                    Route::get('/', 'OauthResourcesController@index');//列表界面
                    Route::get('/<id>', 'OauthResourcesController@edit')->pattern(['id' => '\d+']);//详细界面
                });
                Route::get('/', 'OauthResourcesController@getRecordList'); //获取列表数据
                Route::post('/', 'OauthResourcesController@createRecord'); //添加数据
                Route::put('/<id>', 'OauthResourcesController@updateRecord')->pattern(['id' => '\d+']); //修改数据
                Route::delete('/<id>', 'OauthResourcesController@deleteRecord')->pattern(['id' => '\d+']);//删除数据
            });

            /**
             * 外部接口客户端
             */
            Route::group('clients', function () {
                Route::group('pages', function () {
                    Route::get('/', 'OauthClientsController@index');
                    Route::get('/<id>', 'OauthClientsController@edit')->pattern(['id' => '\d+']);
                });
                Route::get('/', 'OauthClientsController@getRecordList');
                Route::post('/', 'OauthClientsController@createRecord'); //新增数据
                Route::put('/<id>', 'OauthClientsController@updateRecord')->pattern(['id' => '\d+']); //修改数据
                Route::delete('/<id>', 'OauthClientsController@deleteRecord')->pattern(['id' => '\d+']);
                Route::get('/resources', 'OauthClientsController@getResourcesList'); //获取资源列表数据
            });


            /**
             * 外部接口日志
             */
            Route::group('logs', function () {
                Route::group('pages', function () {
                    Route::get('/', 'OauthLogsController@index');
                    Route::get('/<id>', 'OauthLogsController@detail')->pattern(['id' => '[0-9a-zA-Z]+']);
                });
                Route::get('/', 'OauthLogsController@getRecordList');
            });

        });


    })->middleware(['manage.login']);

})->prefix('app\http\Controllers\Manage\\')->middleware(['visit']);